package com.japp.sys.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.japp.base.BaseAction;
import com.japp.sys.bean.SelectBean;
import com.japp.sys.service.SelectService;

@Scope("prototype")
@Controller
public class SelectAction extends BaseAction<SelectBean> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8449954329012953083L;
	@Autowired
	private SelectService selectService;
	
	private SelectBean select = new SelectBean();
	
	/**
	 * 查询所有模板
	 * @return
	 */
	public String querySelectAll() {
		return SUCCESS;
	}
	/**
	 * 分页查询
	 * @return
	 */
	public String querySelect(){
		page = selectService.getPage(page, select);
		return SUCCESS;
	}
	/**
	 * 查询模板（ID）
	 * @return
	 */
	public String findSelectById() {
		return SUCCESS;
	}
	/**
	 * 更新模板
	 * @return
	 */
	public void updateSelectById() {
		int rel = 0;
		if(select.getId()!=0){
			rel = selectService.updateSelect(select );
		}
		if(rel==999){
			result = "模板“"+select .getKey()+"”已存在!";
		}else if(rel!=0){
			result = "模板修改成功!";
		}else{
			result = "模板修改失败!";
		}
		wPrint(result);
	}
	/**
	 * 添加模板
	 * @return
	 */
	public void insertSelectById() {
		int rel = selectService.insertSelect(select );
		if(rel==999){
			result = "模板“"+select .getKey()+"”已存在!";
		}else if(rel!=0){
			result = "模板“"+select .getKey()+"”新增成功!";
		}else{
			result = "模板“"+select .getKey()+"”新增是失败!";
		}
		wPrint(result);
	}
	/**
	 * 删除模板
	 * @return
	 */
	public void deleteSelectById() {
		int rel = selectService.deleteSelectById(keys);
		if(rel!=0){
			result = "模板删除成功!";
		}else{
			result = "模板删除失败!";
		}
		wPrint(result);
	}
	
	public void querySelectTypeAll(){
		String str = selectService.querySelectTypeAll();
		if(str!=null&&!"".equals(str)){
			wPrint(str);
		}
	}
	
	public SelectBean getSelect() {
		return select ;
	}
	public void setSelect(SelectBean select) {
		this.select  = select;
	}
	
}
